package com.chia.multienty.core.rabbitmq.config;

import com.chia.multienty.core.rabbitmq.MultientyRabbitmqConstants;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;

@Configuration
@DependsOn(value = "directExchange")
public class WorkflowImmediateNotifyRabbitConfig {
    @Autowired
    private DirectExchange directExchange;

    @Bean
    public Queue workflowImmediateNotifyQueue() {
        return new Queue(MultientyRabbitmqConstants.WORKFLOW_NOTIFY_QUEUE, true);
    }

    @Bean
    public Binding workflowImmediateBinding() {
        return BindingBuilder
                .bind(workflowImmediateNotifyQueue())
                .to(directExchange)
                .with(MultientyRabbitmqConstants.WORKFLOW_NOTIFY_ROUTING_KEY);
    }
}
